package com.cloud.sample.consumer.core.config;

import com.cloud.sample.consumer.core.http.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.rpc.RpcException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionController {


    @ExceptionHandler(RpcException.class)
    public ApiResponse<String> rpcException(RpcException e) {
        log.debug("服务调用失败({})：{}", e.getCode(), e.getMessage());
        return ApiResponse.build().fail();
    }
}
